package com.dmooo.yxmmerchant.adapter;

import android.support.annotation.Nullable;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.dmooo.yxmmerchant.R;
import com.dmooo.yxmmerchant.domain.ApplyInvoiceBean;

import java.util.List;

public class ApplyInvoiceAdapter extends BaseQuickAdapter<ApplyInvoiceBean.Item, BaseViewHolder> {
    public ApplyInvoiceAdapter(int layoutResId, @Nullable List<ApplyInvoiceBean.Item> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, ApplyInvoiceBean.Item item) {
        if ("1".equals(item.is_treat)) {
            helper.setText(R.id.txt_status, "状态: 待开票");
            helper.getView(R.id.txt_treat).setVisibility(View.VISIBLE);
        } else {
            helper.setText(R.id.txt_status, "状态: 已开票(处理人:"+item.treat_admin+")");
            helper.getView(R.id.txt_treat).setVisibility(View.GONE);
        }
        helper.setText(R.id.txt_name, item.title + " X" + item.num);
        helper.setText(R.id.txt_sku, item.allprice);
        helper.setText(R.id.txt_taitou, item.purchaser + "(" + ("1".equals(item.type) ? "公司" : "个人") + ")");
        helper.setText(R.id.txt_contact, item.linkman);
        helper.setText(R.id.txt_address, item.address);
        helper.setText(R.id.txt_phone, item.contact);
        helper.setText(R.id.txt_tax, item.taxpayer_id);
        helper.addOnClickListener(R.id.txt_detail).addOnClickListener(R.id.txt_treat);
    }
}
